home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / utility3 / jfklib.zip / HELLO.CPP < prev    next >
Text File  |  1991-05-11  |  2KB  |  91 lines

  1. /*
  2.     HELLO.CPP - (C) 1991 by Joachim Kainz 'On a mission from Bhudda'
  3. */
  4.     #include "hello.hpp"
  5.     #include <string.h>
  6.  
  7.     HANDLE hInst;
  8.  
  9.     int PASCAL WinMain (
  10.                 HANDLE    hInst,
  11.                 HANDLE    hPrevInstance,
  12.                 LPSTR    lpCmdLine,
  13.                 int        nCmdShow
  14.                )
  15.     {
  16.         SetInstance (hInst);
  17.  
  18.         HELLO hello (nCmdShow);
  19.  
  20.         if (!IsWindow (hello))
  21.             return FALSE;
  22.  
  23.         return MsgLoop (hello);
  24.     }
  25.  
  26.     HELLO::HELLO (int nCmdShow) : TOPLEVEL (nCmdShow)
  27.     {
  28.         LOGFONT lf;
  29.  
  30.         memset (&lf, 0, sizeof lf);
  31.  
  32.         LoadString (
  33.             GetInstance (),
  34.             ID_FONT,
  35.             (LPSTR) lf.lfFaceName,
  36.             sizeof lf.lfFaceName
  37.         );
  38.         lf.lfHeight = 38;
  39.         lf.lfWidth  = 50;
  40.  
  41.         hFont  = CreateFontIndirect (&lf);
  42.         pTitle = new char [20];
  43.  
  44.         LoadString (GetInstance (), ID_HI_FOLKS, pTitle, 20);
  45.     }
  46.  
  47.     METHOD HELLO::WMClose ()
  48.     {
  49.         delete pTitle;
  50.  
  51.         DeleteObject (hFont);
  52.  
  53.         DestroyWindow (GetWindowHandle ());
  54.  
  55.         return 0l;
  56.     }
  57.  
  58.     METHOD HELLO::WMPaint()
  59.     {
  60.         PAINTSTRUCT ps;
  61.         RECT        rt;
  62.  
  63.         BeginPaint      (GetWindowHandle (), &ps);
  64.  
  65.         SetMapMode       (ps.hdc,         MM_ANISOTROPIC);
  66.         GetClientRect  (GetWindowHandle (),     &rt);
  67.         SetViewportExt (ps.hdc, rt.right, rt.bottom);
  68.         SetWindowOrg   (ps.hdc, 0,    0                  );
  69.  
  70.         rt.right  = 450;
  71.         rt.bottom = 40;
  72.  
  73.         SetWindowExt (ps.hdc, rt.right, rt.bottom);
  74.  
  75.         HFONT hOldFont = SelectObject (ps.hdc, hFont);
  76.  
  77.         DrawText (
  78.             ps.hdc,
  79.             pTitle,
  80.             -1,
  81.             &rt,
  82.             DT_CENTER | DT_VCENTER | DT_SINGLELINE
  83.         );
  84.  
  85.         SelectObject (ps.hdc, hOldFont);
  86.  
  87.         EndPaint  (GetWindowHandle (), &ps);
  88.  
  89.         return 0l;
  90.     }
  91.